import sys
import os

#Joseph Jessup
#Says it Fails on Line 0 !-! There is No Line 0

lineNum = 0

def ReadFile():
    lineNum = 0
    line = 'start'
    while len(line) != 0:
        line = file.readline()
        ++lineNum
        parse(line)

def parse(line):
    tokens = line.split('<')
    
    if len(tokens) == 2:
        
        #check if follow tag format
        if tokens[1][1].isalpha():
            endF = 1
            for i in range(1,len(tokens[1])):
                if tokens[1][i] == '>':
                    endF = 0
                    break
                else:
                    endF = 1
            if endF == 1:
                print('FAILLLLLLLLLLLLLLLLLLLLLLL' + ' ' + str(lineNum))
            #else:
             #   print('good')
                
        elif tokens[1][1] == '/':
            if tokens[1][2].isalpha():
                endF = 1
                for i in range(2,len(tokens[1])):
                    if tokens[1][i] == '>':
                        endF = 0
                        break
                    else:
                        endF = 1
                if endF == 1:
                    print('FAILLLLLLLLLLLLLLLLLLLLLLL' + ' ' + str(lineNum))
                else:
                    print('good')
                    
        else:
            print('FAILLLLLLLLLLLLLLLLLLLLLLLLLLLLL' + ' ' + str(lineNum))
        
    elif len(tokens) == 3:
        #other stuff
        #for i in range(0,len(tokens)):
         #   data = tokens[i].split('>')
         #   print('blah')
         for i in range(1,len(tokens)):
             tokens[i] = '<' + tokens[i]
             parse(tokens[i])
             #print('reparse')
        
    else:
        print('NEW TESTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTttt')

file = open(os.getcwd() + '\\motion0.xml')
ReadFile()

file = open(os.getcwd() + '\\motion0.xml')
ReadFile()

file = open(os.getcwd() + '\\motion0.xml')
ReadFile()

file = open(os.getcwd() + '\\motion0.xml')
ReadFile()
